![]() ![]() |
Q: While browsing for Rendezvous services using CFNetSevices, NSNetServices or DNSServiceDiscovery, I sometimes get multiple "Add" events containing identical service names. Why does that happen? A: This happens when your computer has more than one network interface enabled because, by default, Rendezvous browses on all active interfaces. So for example, if your computer has an Ethernet connection and an AirPort connection, and a service is being advertised on both Ethernet and AirPort, your callback will be called twice containing the same service name. With CFNetServices and NSNetSerivces, there's no way to know which network interface the service was discovered on, so it's best to assume that both service names represent the same service. You probably don't want to show the same name multiple times in a list of services, so you should do reference counting of each service name. Every time you get an "Add" event for a service name you should increment the reference count, and for each "Remove" event, you should decrement the reference count. When the reference count reaches zero, you should remove the service name from your browser list. When it comes time to Resolve a service that was discovered on multiple network interfaces, it makes no difference which CFNetServiceRef or NSNetService object you use to initiate the Resolve, because the Resolve query gets sent on every network interface. With the newer DNSServiceDiscovery API, located in [Feb 06, 2004] |
Developer Documentation | Technical Notes | Development Kits | Sample Code |